let user ={
    name:"john",
    money:1000,
    // [Symbol.toPrimitive](hint){
    //     console.log(`hint:${hint}`);
    //     return hint
    // },
    toString(){
        console.log('调用toString');
        return 'toString'
    },
    valueOf(){
        console.log('调用valueof');
        return 'valuof'
    }
    
}

//console.log(user);//不会触发类型转换
// let a =[]

// Array.prototype.valueOf=function(){
//     console.log('调用valueof');
// }
// Array.prototype.toString=function(){
//     console.log('调用toString');
// }
//alert(user)// hint:string 调用 string
user + 0;//default 调用valueOf

user + '0';//default 调用valueOf
+user; //调用valueOf
user + user //调用valueOf
console.log({}+{});//[object Object][object Object]
console.log({}+[]);//[object Object]
console.log([].valueOf()+{}.valueOf());//[object Object]
console.log([]==0);//true
console.log([2]==2);//true
console.log([null]==0);//true
console.log([undefined]==0);//true
console.log(undefined==false);//false




// console.log({}[Symbol.toPrimitive]);//undefined
// console.log([1,2,3][Symbol.toPrimitive]);//undefined
// console.log(Function[Symbol.toPrimitive]);//undefined